<template>
	<view>
		<cu-custom bgColor="bg-white" :isBack="true">
			<block slot="backText">返回</block>
			<block slot="content">客户审批</block>
		</cu-custom>
		<!-- 顶部导航 -->
		<view>

			<!-- 考虑非APP端长列表和复杂的DOM使用scroll-view会卡顿，所以漂浮顶部选项卡使用page本身的滑动 -->

			<view>
				<view class="list">
					<view class="row" v-if="total != 0">
						<uni-list v-for="(row,index) in list" :key="index" style="margin-bottom: 5px;margin-top: 5px;">
							<uni-list-item v-if="!row.deleted" :title="'客户名称：' + row.name" link :note="'业务员：' + row.bizName" :rightText="row.approved?'已审核':'未审批'" @click="approveDetailGo(row)"></uni-list-item>
						</uni-list>

						<!-- <view class="btns">
							<view class="bill" :data-id="row.BillNo">订单金额：￥</view>
							<view class="con">
								<block v-if="row.type=='unpaid'">
									<view class="default" @tap="cancelOrder(row)">取消</view>
								</block>
								<block v-if="row.type=='back'">
								</block>
							</view>
						</view> -->
					</view>
					<view class="ondata" v-if="total == 0">
						<view class="text">
							这里空空如也~~
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>
<script>
	import {
		uniRow,
		uniCol
	} from '@dcloudio/uni-ui'

	import {
		getCustomerListApi,
	} from "@/server/config.js";

	import {
		toLogin,
		formatDate,
	} from "@/server/api.js";
	export default {
		components: {
			uniRow,
			uniCol
		},

		onLoad(options) {
			console.info('onload')
			this.fetData()
		},
		onShow() {
			toLogin();
		},
		onReachBottom() {
			// this.page = this.page + 1;
			// if (this.page > this.total) {
			//     return false;
			// }
			// this.getOrderList();
		},
		created() {

		},
		mounted() {

			// this.getOrderList(true);
		},
		data() {
			return {
				//订单列表 演示数据
				list: [],
				tabbarIndex: 0,
				pageNo: 1,
				pageSize: 20,
				total: "",
			};
		},
		onPageScroll(e) {
			return;
			//兼容iOS端下拉时顶部漂移
			this.headerPosition = e.scrollTop >= 0 ? "fixed" : "absolute";
		},

		methods: {
			async fetData() {
				let result = await getCustomerListApi({
					createDate: formatDate(new Date()),
					pageNo: this.pageNo,
					pageSize: this.pageSize
				});
				this.list = result.data.records
				this.total = result.data.totalElement
			},

			approveDetailGo(row) {
				let _this = this
				uni.navigateTo({
					url: "/apiMember/approvedetail/main",
					events: {
						acceptDataFromOpenedPage: function(data) {
							let customer = data.data
							//会员删除的情况下，需要移除数据
							if(customer.deleted){
								
							}
						},
					},
					success: function(res) {
						// 通过eventChannel向被打开页面传送数据
						res.eventChannel.emit('acceptDataFromOpenerPage', {
							data: row
						})
					}
				});
			},

		},

	};
</script>

<style lang="scss">
	@import "./style.scss";
</style>
